<template>
  <div class="pc" v-if="store.state.isPc">
    <div class="header">{{ servetitle }}</div>
    <div class="headbg">
      <p>
        {{ details.value.school_name }}<span>({{ details.value.area }})</span>
      </p>
      <img src="../../../assets/schoolbg.png" alt="" />
    </div>
    <div class="noticedetails">
      <div class="container">
        <div class="breadcrumb">
          <ul class="tab">
            <li
              :class="{ active: type == item.id }"
              @click="cuttype(item.id)"
              v-for="item in typelist.value"
              :key="item.id"
            >
              {{ item.class_name }}列表
            </li>
          </ul>
          <el-breadcrumb separator="》">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item
              :to="{
                path: '/school',
                query: {
                  class_id: $route.query.class_id,
                  name: $route.query.name,
                },
              }"
              >{{ $route.query.name }}</el-breadcrumb-item
            >
            <el-breadcrumb-item>详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="box">
          <ul class="left">
            <li
              :class="{ active: label == item.label_id }"
              @click="cutlabel(item.label_id)"
              v-for="item in labellist.value"
              :key="item.label_id"
            >
              {{ item.name }}
            </li>
          </ul>
          <div class="right">
            <div class="title">
              <p>{{ details.value?.name }}</p>
            </div>
            <!-- <div class="info">
            <span>
              发布时间：{{ timestampToTime(details.value?.create_time) }}</span
            >
            <span
              >来源：<span class="sgreen">{{
                details.value?.source
              }}</span></span
            >
          </div> -->
            <div class="contentbox" v-for="item in details.value?.content">
              <div class="name">{{ item.title }}</div>
              <div class="content" v-html="item.text"></div>
            </div>
          </div>
        </div>
        <div class="cooperation" @click="godialog">
          我<br />
          要<br />
          合<br />
          作
        </div>
      </div>
    </div>

    <div class="foot">
      <div class="top">
        <p>
          指导单位：全国文化艺术职业教育教学指导委员会&nbsp;&nbsp;&nbsp;中国艺术职业教育学会
        </p>
        <p>
          主办单位：全国文化艺术职业教育教学指导委员会对外交流与合作专委会&nbsp;&nbsp;&nbsp;教学质量评价与保障专委会
        </p>
        <p>承办单位：深圳艺术学校&nbsp;&nbsp;&nbsp;浙江艺术职业学院</p>
        <p>技术支持单位：广州市晨旭教育评估有限公司</p>
      </div>
      <div class="bottom">
        <p>ICP备15112809号-2</p>
      </div>
      <el-dialog
        v-model="dialogVisible"
        width="435px"
        :show-close="false"
        :before-close="godialog"
        custom-class="eldia"
      >
        <div class="title">我要合作</div>
        <el-input v-model="obj.phone" placeholder="请输入联系方式" />
        <el-input v-model="obj.username" placeholder="请输入用户名称" />
        <el-input v-model="obj.school" placeholder="请输入学校名称" />
        <el-input
          v-model="obj.need"
          placeholder="请输入您的需求"
          show-word-limit
          type="textarea"
          rows="4"
        />
        <el-button type="primary" @click="sumbit">提交</el-button>
      </el-dialog>
    </div>
  </div>
  <div class="mob" v-else>
    <div class="header">{{ servetitle }}</div>
    <div class="headbg">
      <p>
        {{ details.value.school_name }}<span>({{ details.value.area }})</span>
      </p>
      <img src="../../../assets/schoolbg.png" alt="" />
    </div>
    <div class="noticedetails">
      <div class="container">
        <div class="breadcrumb">
          <div class="menu" @click="navshow = !navshow">
            <el-icon><Menu /></el-icon>
          </div>

          <div class="tab" v-if="navshow">
            <van-nav-bar
              title="标题"
              left-text="返回"
              left-arrow
              @click-left="navshow = !navshow"
            />

            <van-collapse
              v-model="collapsearr.value"
              :accordion="true"
              :border="true"
              @change="cuttypemob"
            >
              <van-collapse-item
                :title="item.class_name"
                :name="item.id"
                v-for="item in typelist.value"
                :key="item.id"
              >
                <ul>
                  <li
                    v-for="item1 in labellist.value"
                    :key="item1.id"
                    @click="cutlabel(item1.label_id)"
                  >
                    {{ item1.name }}
                  </li>
                </ul>
              </van-collapse-item>
            </van-collapse>
          </div>
          <el-breadcrumb separator="》">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item
              :to="{
                path: '/school',
                query: {
                  class_id: $route.query.class_id,
                  name: $route.query.name,
                },
              }"
              >{{ $route.query.name }}</el-breadcrumb-item
            >
            <el-breadcrumb-item>详情</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <div class="contentbox" v-for="item in details.value?.content">
          <div class="name">{{ item.title }}</div>
          <div class="content" v-html="item.text"></div>
        </div>
      </div>
    </div>
    <div class="foot">
      <p>
        指导单位：全国文化艺术职业教育教学指导委员会&nbsp;&nbsp;&nbsp;中国艺术职业教育学会
      </p>
      <p>
        主办单位：全国文化艺术职业教育教学指导委员会对外交流与合作专委会&nbsp;&nbsp;&nbsp;教学质量评价与保障专委会
      </p>
      <p>承办单位：深圳艺术学校&nbsp;&nbsp;&nbsp;浙江艺术职业学院</p>
      <p>技术支持单位：广州市晨旭教育评估有限公司</p>
      <p>ICP备15112809号-2</p>
    </div>
    <van-floating-bubble
      icon="chat"
      @click="godialog"
      style="background: #271c9f"
    />
    <!-- <div class="cooperation" @click="godialog">
        我<br />
        要<br />
        合<br />
        作
      </div> -->
    <el-dialog
      v-model="dialogVisible"
      :show-close="false"
      :before-close="godialog"
      custom-class="eldia"
    >
      <div class="title">我要合作</div>
      <el-input v-model="obj.phone" placeholder="请输入联系方式" />
      <el-input v-model="obj.username" placeholder="请输入用户名称" />
      <el-input v-model="obj.school" placeholder="请输入学校名称" />
      <el-input
        v-model="obj.need"
        placeholder="请输入您的需求"
        show-word-limit
        type="textarea"
        rows="4"
      />
      <el-button type="primary" @click="sumbit">提交</el-button>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
import { defineComponent, reactive, watch, ref, onMounted } from "vue";
import {
  labelClassLists,
  cooperate,
  allSchoolLabel,
  schoolDetails,
  serveTitile,
} from "../../../api/api";
import { Menu } from "@element-plus/icons-vue";
import { useRoute, useRouter } from "vue-router";
import { ElMessage, messageConfig, ElNotification } from "element-plus";
import { timestampToTime } from "../../../utils/utils";
import { useStore } from "vuex";
let $route = useRoute();
let $router = useRouter();
let store = useStore();
let navshow = ref(false);
onMounted(() => {
  gettypelist();
});

let servetitle = ref("");
const gettitle = () => {
  serveTitile({}).then((res) => {
    servetitle.value = res.data.title;
  });
};
gettitle();
//--------------------------------------------------获取列表
let collapsearr = reactive({ value: [] });
let type: any = ref(0);
let typelist: any = reactive({ value: [] });
const gettypelist = () => {
  labelClassLists({}).then((res) => {
    typelist.value = res.data;
    if (
      $route.query.type != "undefined" &&
      $route.query.type != undefined &&
      $route.query.type != null
    ) {
      type.value = $route.query.type;
    } else {
      type.value = res.data[0]?.id;
    }

    getlabellist();
  });
};

const cuttype = (id: any) => {
  type.value = id;
  getlabellist();
};

const cuttypemob = (id: any) => {
  type.value = id;
  allSchoolLabel({
    school_id: $route.query.schoolid,
    label_class_id: type.value,
  }).then((res) => {
    labellist.value = res.data;

    label.value =
      $route.query.id != "undefined" ? $route.query.id : res.data[0].label_id;
  });
};

//-------------------------------------------------- end获取列表

//---------------------------------------------------获取标签列表

let label = ref(0);
let labellist: any = reactive({ value: [] });
const getlabellist = () => {
  allSchoolLabel({
    school_id: $route.query.schoolid,
    label_class_id: type.value,
  }).then((res) => {
    labellist.value = res.data;
    label.value =
      $route.query.id != "undefined" ? $route.query.id : res.data[0].label_id;
    getdetails();
  });
};

const cutlabel = (id: number) => {
  label.value = id;
  getdetails();
};

//---------------------------------------------------end获取标签列表

//--------------------------------------------------获取详情

let details: any = reactive({ value: {} });
const getdetails = () => {
  schoolDetails({ label_id: label.value }).then((res) => {
    details.value = res.data;
    navshow.value = false;
    console.log(details.value);
    // details.value.content = details.value.content.replace(/&nbsp;/ig, '&ensp;');
    details.value?.content.forEach((item: any, index: number) => {
      item.text = item.text.content.replace(/&nbsp;/gi, "&ensp;");
    });
  });
};
//--------------------------------------------------end获取详情

let dialogVisible = ref(false);
const godialog = () => {
  dialogVisible.value = !dialogVisible.value;
};

let obj = reactive({
  phone: "",
  username: "",
  school: "",
  need: "",
});

console.log($route.query);

const sumbit = () => {
  if (obj.phone == "") {
    ElMessage.warning("请填写手机号");
    return;
  }
  if (obj.username == "") {
    ElMessage.warning("请填写用户名称");
    return;
  }
  if (obj.school == "") {
    ElMessage.warning("请填写学校名称");
    return;
  }
  if (obj.need == "") {
    ElMessage.warning("请填写需求");
    return;
  }

  cooperate({
    mobile_number: obj.phone,
    name: obj.username,
    school_name: obj.school,
    demand: obj.need,
    class_id: label.value,
  }).then((res) => {
    godialog();
    obj.phone = "";
    obj.username = "";
    obj.school = "";
    obj.need = "";
    ElNotification({
      title: "成功",
      message: h("i", {}, "提交成功"),
    });
  });
};
</script>

<style lang="scss" scoped>
.pc {
  .header {
    width: 100%;
    height: 80px;
    background: linear-gradient(56deg, #23179d 6%, #4448ae 100%);
    border-radius: 0px 0px 0px 0px;
    opacity: 1;
    text-align: center;
    line-height: 80px;
    font-size: 22px;
    font-family: Alibaba PuHuiTi 2-75 SemiBold, Alibaba PuHuiTi 20;
    font-weight: 600;
    color: #ffffff;
  }
  .headbg {
    width: 100%;
    height: 300px;

    position: relative;
    p {
      position: absolute;
      top: 40%;
      left: 0;
      text-align: center;
      width: 100%;
      font-size: 48px;
      font-family: Source Han Sans-Bold, Source Han Sans;
      font-weight: 700;
      color: #2a1fb1;
      z-index: 99;
      span {
        font-size: 20px;
        font-family: Source Han Sans-Bold, Source Han Sans;
        font-weight: 700;
        color: #2a1fb1;
        margin-left: 10px;
      }
    }
    img {
      height: 320px;
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  .noticedetails {
    background: #f7f9ff;
    min-height: 900px;
    position: relative;
    .container {
      border-radius: 5px;
      margin: 0 auto;
      background: #f9f9f9;
      width: 1400px;
      .breadcrumb {
        height: 64px;
        border-bottom: 1px solid #dadada;
        background: white;
        width: 1400px;
        .tab {
          width: 280px;
          float: left;
          display: flex;
          padding: 0 10px;
          justify-content: space-evenly;
          li {
            margin-top: 19px;
            width: 115px;
            height: 44px;
            cursor: pointer;
            background: #eeeeee;
            font-size: 18px;
            font-family: Source Han Sans-Regular, Source Han Sans;
            font-weight: 400;
            color: #353535;
            text-align: center;
            line-height: 44px;
          }
          .active {
            background: rgba(74, 69, 255, 0.1);
            color: #2a1fb1;
          }
        }
        :deep(.el-breadcrumb) {
          height: 64px;
          line-height: 64px;
          max-width: 340px;
          min-width: 100px;
          float: right;
          padding-right: 50px;
          .el-breadcrumb__item {
            &:nth-child(1) {
              .is-link {
                color: #666666 !important;
                font: size 16px;
                font-family: Source Han Sans-Regular, Source Han Sans;
                font-weight: 400;
              }
            }
            &:nth-child(2) {
              .is-link {
                color: #666666 !important;
                font: size 16px;
                font-family: Source Han Sans-Regular, Source Han Sans;
                font-weight: 400;
              }
            }
          }
        }
      }
      .box {
        display: flex;
        justify-content: space-between;
        min-height: 800px;
        .left {
          width: 280px;
          float: left;
          background: #ffffff;
          padding-top: 25px;
          li {
            padding: 20px 25px;
            width: 100%;
            font-size: 18px;
            font-family: Source Han Sans-Regular, Source Han Sans;
            font-weight: 400;
            color: #3d3d3d;
            line-height: 25px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            text-overflow: ellipsis;
            overflow: hidden;
            -webkit-box-orient: vertical;
            border-bottom: 1px solid #ececec;
            cursor: pointer;
          }
          .active {
            color: #0d0a65;
          }
        }
        .right {
          width: 1088px;
          float: right;
          background: #ffffff;
          padding: 0 75px;
          padding-bottom: 80px;
          .title {
            height: 130px;

            text-align: center;
            font-size: 30px;
            font-family: Source Han Sans-Regular, Source Han Sans;
            font-weight: 400;
            color: #000000;
            position: relative;
            p {
              position: absolute;
              left: 0;
              top: 50%;
              width: 100%;
              text-align: center;
              transform: translateY(-50%);
              display: block;
            }
          }
          .info {
            color: #999;
            font-size: 15px;
            margin: 0 auto;
            margin-top: 15px;
            text-align: center;
            background: #f1f3f9;
            width: 928px;
            height: 44px;
            span {
              margin: 0 15px;
              font-size: 16px;
              line-height: 44px;
              font-family: Source Han Sans-Regular, Source Han Sans;
              font-weight: 400;
              color: #666666;
            }
          }
          .contentbox {
            margin-bottom: 15px;
            .name {
              font-size: 18px;
              font-family: Source Han Sans-Regular, Source Han Sans;
              font-weight: 600;
              line-height: 32px;
            }
            .content {
              font-size: 18px;
              font-family: Source Han Sans-Regular, Source Han Sans;
              font-weight: 400;
              color: #3d3d3d;
              line-height: 32px;
            }
          }
        }
      }
    }
  }
  .foot {
    width: 100%;
    height: 270px;
    background: url("../../../assets/footbg.png") no-repeat;
    background-size: 100% 100%;
    .top {
      height: 220px;
      width: 1400px;
      margin: 0 auto;
      box-sizing: border-box;
      padding-top: 40px;
      p {
        font-size: 18px;
        font-family: Source Han Sans-Regular, Source Han Sans;
        font-weight: 400;
        color: #ffffff;
        line-height: 36px;
      }
    }
    .bottom {
      height: 48px;
      border-top: 1px solid #dadada;
      p {
        line-height: 48px;
        text-align: center;
        font-size: 18px;
        font-family: Source Han Sans-Regular, Source Han Sans;
        font-weight: 400;
        color: #ffffff;
      }
    }
  }
  .cooperation {
    background: url("../../../assets/cooperationbg.png");
    width: 80px;
    height: 180px;
    text-align: center;
    color: white;
    text-align: center;
    line-height: 30px;
    padding-top: 25px;
    padding-left: 14px;
    cursor: pointer;
    position: fixed;
    right: 15px;
    top: 60%;
    border-radius: 40px;
    overflow: hidden;
    font-size: 22px;
    font-family: Source Han Sans-Regular, Source Han Sans;
    font-weight: 700;
  }
  :deep(.eldia) {
    width: 435px;
    height: 502px;
    padding: 0 30px;
    background: url("../../../assets/diabg.png");
    .el-dialog__header {
      display: none;
    }
    .title {
      height: 94px;
      line-height: 94px;
      font-size: 24px;
      font-family: Source Han Sans-Medium, Source Han Sans;
      font-weight: 500;
      color: #0c1770;
      text-align: center;
    }
    .el-input {
      margin-bottom: 15px;
      .el-input__wrapper {
        height: 40px;
      }
    }
    .el-button {
      margin-top: 42px;
      width: 100%;
      height: 42px;
      line-height: 42px;
    }
  }
}
.mob {
  .header {
    width: 100%;
    height: 5rem;
    background: linear-gradient(56deg, #23179d 6%, #4448ae 100%);
    border-radius: 0px 0px 0px 0px;
    opacity: 1;
    text-align: center;
    line-height: 5rem;
    font-size: 1.375rem;
    font-family: Alibaba PuHuiTi 2-75 SemiBold, Alibaba PuHuiTi 20;
    font-weight: 600;
    color: #ffffff;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .headbg {
    width: 100%;
    height: 18.75rem;

    position: relative;
    p {
      position: absolute;
      top: 40%;
      left: 0;
      text-align: center;
      width: 100%;
      font-size: 3rem;
      font-family: Source Han Sans-Bold, Source Han Sans;
      font-weight: 700;
      color: #2a1fb1;
      z-index: 99;
      span {
        font-size: 1.25rem;
        font-family: Source Han Sans-Bold, Source Han Sans;
        font-weight: 700;
        color: #2a1fb1;
        margin-left: 0.625rem;
      }
    }
    img {
      height: 20rem;
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  .noticedetails {
    background: #f7f9ff;
    min-height: 56.25rem;
    position: relative;
    .container {
      border-radius: 5px;
      margin: 0 auto;
      background: #f9f9f9;
      width: 46.875rem;
      position: relative;
      .breadcrumb {
        height: 5rem;
        border-bottom: 1px solid #dadada;
        background: white;
        width: 46.875rem;
        .tab {
          width: 100%;
          height: 100vh;
          position: fixed;
          top: 0;
          left: 0;
          z-index: 999;
          background: white;
          ul {
            padding: 15px;
            li {
              height: 5.375rem;
              line-height: 5.375rem;
              padding-left: 20px;

              border-bottom: 1px solid #ccc;
              a {
                color: #0d0a65;
                font-size: 20px;
                font-weight: bold;
              }
            }
          }
        }
        .menu {
          width: 5rem;
          height: 5rem;
          text-align: center;
          float: left;
          line-height: 5rem;
          font-size: 1.875rem;
          margin-left: 1.875rem;
          color: color(srgb red green blue);
        }
        :deep(.el-breadcrumb) {
          height: 5rem;
          line-height: 5rem;
          min-width: 6.25rem;
          float: right;
          padding-right: 3.125rem;
          .el-breadcrumb__item {
            &:nth-child(1) {
              .is-link {
                color: #666666 !important;
                font: size 1rem;
                font-family: Source Han Sans-Regular, Source Han Sans;
                font-weight: 400;
              }
            }
            &:nth-child(2) {
              .is-link {
                color: #666666 !important;
                font: size 1rem;
                font-family: Source Han Sans-Regular, Source Han Sans;
                font-weight: 400;
              }
            }
          }
        }
      }
      .contentbox {
        margin: 1.25rem;
        width: calc(100% - 2.5rem);
        min-height: 1.875rem;
        padding: 1.875rem;
        background: white;
        border-radius: 10px;
        font-size: 1.875rem;
        .name {
          color: #23179d;
          margin-bottom: 10px;
        }
      }
    }
  }

  .cooperation {
    background: url("../../../assets/cooperationbg.png");
    width: 80px;
    height: 180px;
    text-align: center;
    color: white;
    text-align: center;
    line-height: 30px;
    padding-top: 25px;
    padding-left: 14px;
    cursor: pointer;
    position: fixed;
    right: 15px;
    top: 60%;
    border-radius: 40px;
    overflow: hidden;
    font-size: 22px;
    font-family: Source Han Sans-Regular, Source Han Sans;
    font-weight: 700;
  }
  :deep(.eldia) {
    width: 43.75rem;
    padding: 0 1.875rem;
    background: url("../../../assets/diabg.png");
    .el-dialog__header {
      display: none;
    }
    .title {
      height: 12.5rem;
      line-height: 5.875rem;
      font-size: 3rem;
      font-family: Source Han Sans-Medium, Source Han Sans;
      font-weight: 500;
      color: #0c1770;
      text-align: center;
    }
    .el-input {
      margin-bottom: 1rem;

      .el-input__wrapper {
        height: 5.5rem;
      }
    }
    .el-button {
      margin-top: 2.625rem;
      width: 100%;
      height: 4.625rem;
      line-height: 4.625rem;
    }
  }
  .foot {
    background: #0c0d67;
    width: 46.875rem;
    height: 15.625rem;
    color: rgb(245, 245, 245);
    font-size: 1.125rem;
    padding: 0 1.5rem;
    padding-top: 2.1875rem;
    line-height: 1.875rem;
  }
}
</style>
